// File EntityManager.h
//
// Purpose: Singleton class to handle the  management of Entities.
//
// Author : Bryson King (edited)
// Original Code Provided by: Mat Buckland 2002 (fup@ai-junkie.com)
// Date : 18 March 2013
// --------------------------------------------------------------
#ifndef ENTITYMANAGER_H
#define ENTITYMANAGER_H

#include <map>

class CBaseGameEntity;

//provide easy access
#define EntityMgr CEntityManager::Instance()

class CEntityManager
{
public:
	static CEntityManager* Instance();

	//this method stores a pointer to the entity in the std::vector
	//m_Entities at the index position indicated by the entity's ID
	//(makes for faster access)
	void RegisterEntity(CBaseGameEntity* NewEntity);

	//returns a pointer to the entity with the ID given as a parameter
	CBaseGameEntity* GetEntityFromID(int id)const;

	//this method removes the entity from the list
	void RemoveEntity(CBaseGameEntity* pEntity);

private:
	typedef std::map<int, CBaseGameEntity*> EntityMap;

	//to facilitate quick lookup the entities are stored in a std::map, in which
	//pointers to entities are cross referenced by their identifying number
	EntityMap m_EntityMap;

	CEntityManager(){}

	//copy ctor and assignment should be private
	CEntityManager(const CEntityManager&);
	CEntityManager& operator=(const CEntityManager&);
};

#endif